#include "rose.h"
#include "Argument.h"
#include "FunctionCall.h"
#include "VariableWrapper.h"
using namespace std;

#ifndef FUNCTION_CONTEXT_H
#define FUNCTION_CONTEXT_H

class FunctionContext;
class analyzeTraversal;


class FunctionContext {
    public:
        FunctionContext(SgFunctionDeclaration *set_decl, analyzeTraversal *set_all);
        void addCall(FullFunctionCall *call);
        VariableWrapper *addLocal(SgVariableDeclaration *local);
        void addCaller(FunctionContext *fc, FullFunctionCall *);
        void appendWrites(Reference **, int);
        void appendReads(Reference **, int);
        string str();
        string get_name();
        SgFunctionDeclaration *get_decl();
        void confirmFunction();
        int isConfirmed();
        int n_args();
        VariableWrapper *ithParam(int index) { return parameters[index]; }
        VariableWrapper *verySimpleResolve(string name);
        VariableWrapper *findVarByDecl(SgDeclarationStatement *decl);
        VariableWrapper *findVarByName(string name);
    private:
        SgFunctionDeclaration *decl;
        FullFunctionCall **function_calls;
        VariableWrapper **parameters;
        VariableWrapper **local_variables;
        FunctionContext **callers;
        FullFunctionCall **calls_this;
        Reference **writes;
        Reference **reads;
        int n_reads;
        int n_writes;
        int n_calls;
        int n_local_vars;
        int n_callers;
        int function_confirmed;
        analyzeTraversal *all;


        int contains(Reference **arr, Reference *ref, int N);
};

#endif
